#ifndef _BS_H_
#define _BS_H_

// utilities and system includes
#include <CL/cl.h>
#include <CL/cl_platform.h>
#include <CL/cl_ext.h>
#include <CL/opencl.h>

#include <cmath>
#include <cstdlib>
#include <cstdio>
#include "util.h"


#define ERR_CHECK(errcode, str) \
	if ((errcode) != CL_SUCCESS) fprintf(stderr, "%s:%u: %s=%s\n", __FILE__, __LINE__, str, oclErrorString(errcode))

typedef struct BS_test {
	cl_context hContext;
	cl_command_queue hCmdQueue;
	cl_kernel hBSKernel; 

	cl_float * h_CallResult;
	cl_float * h_PutResult;
	cl_float * h_StockPrice;
	cl_float * h_OptionStrike;
	cl_float * h_OptionYears;

	cl_mem d_CallResult;
	cl_mem d_PutResult;
	cl_mem d_StockPrice;
	cl_mem d_OptionStrike;
	cl_mem d_OptionYears;

	cl_float Riskfree;
	cl_float Volatility;

	size_t blockSize;
	size_t maxBlockSize;
	size_t gridSize;
	cl_uint num;
	double time;
	int run_num_iters;
} BS_test_t;

double launch_BS(BS_test_t * t);

#endif // #ifndef _BS_H_